package com.wfm.mianshi;

public class Demo2 {
    public static void main(String[] args) {
        int n = 23123;
        int[] arr = {2, 4, 9};
        int res = findMaxNumber(n, arr);
        System.out.println(res);
    }

    public static int findMaxNumber(int n, int[] arr) {
        int res = n - 1;
        while (res > 0) {
            boolean isMax = true;
            for (int num : arr) {
                if (res % num == 0) {
                    isMax = false;
                    break;
                }
            }
            if (isMax) {
                return res;
            }
            res--;
        }
        return -1; // If no number smaller than n and not divisible by any number in arr is found
    }
}
